import mongoose from '../dbHelper';
import {defaultSchemaExtend, defaultSchemaOptions} from "../config/index";
import moment from 'moment'

const Schema = mongoose.Schema;
// 自动删除30日后的数据
const DlyAdminLinkClickSchema = new Schema(Object.assign({
    clicks: { // 点击次数
        type: Number,
        default: 1
    },
    uuId: String, // 唯一标识
    linkId: {
        type: Schema.Types.ObjectId,
        ref: 'DlyAdminLink'
    },
    proxyId: {
        type: Schema.Types.ObjectId,
        ref: 'DlyAdminUser'
    },
    uuUser: {
        type: Schema.Types.ObjectId,
        ref: 'DlyAdminShopUser'
    },
    ip: String, // 用户ip
    createdAt: {
        type: Date,
        index: {expires: 60 * 60 * 24 * 30} // 数据过期时间一个月
    }
 
}, defaultSchemaExtend), defaultSchemaOptions);

const DlyAdminLink = mongoose.model('DlyAdminLinkClick', DlyAdminLinkClickSchema, 'DlyAdminLinkClicks');

export default DlyAdminLink